package base.utils

import android.os.CountDownTimer
import android.widget.TextView

/**
 * @author njmsir
 * Created by njmsir on 2017/9/21.
 */
class CountDownTimerUtils(millisInFuture: Long, countDownInterval: Long, private var textView: TextView) : CountDownTimer(millisInFuture, countDownInterval) {
    init {
        textView.width = textView.width
    }

    /**
     * 倒计时期间会调用的方法
     */
    override fun onTick(millisUntilFinished: Long) {
        textView.isClickable = false
        textView.text = (millisUntilFinished / 1000).toString() + "s"
    }

    override fun onFinish() {
        textView.text = "获取验证码"
        textView.isClickable = true
    }
}